﻿using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;

namespace UI.Views.component;

public partial class UserLogin : UserControl
{
    public UserLogin()
    {
        InitializeComponent();
    }
    
    // 自定义属性
    public static readonly StyledProperty<string> TitleProperty =
        AvaloniaProperty.Register<UserLogin, string>(nameof(Title), "Default Title");

    public string Title
    {
        get => GetValue(TitleProperty);
        set => SetValue(TitleProperty, value);
    }

    // 事件处理
    private void OnButtonClick(object? sender, RoutedEventArgs e)
    {
        // 触发自定义事件
        ButtonClicked?.Invoke(this, EventArgs.Empty);
        Console.WriteLine($"Button clicked! Title: {Title}" + "userLogin onClick......");
    }

    // 自定义事件
    public event EventHandler? ButtonClicked;
}